﻿create or replace function addressToXml(bigint, text)
returns xml as
$$
declare
  addressId alias for $1;
  addressName alias for $2;
begin

  return
	xmlelement( 
		name address, xmlattributes(addressId as id), xmlelement(name addressname, addressName)
		)
  ;

end;
$$ language plpgsql IMMUTABLE; -- same result for same data